<script>
	import {mapMutations} from 'vuex'
	import {AppInfo} from './utils/AppInfo'
	import {Dict} from './utils/filter'
	import {RequestApi} from './service/requestApi'
	import {refreshlogin} from './utils/user'
	const app = AppInfo.getInstance()
	export default {
		onLaunch: async function(options) {
			await this.getDict()
			// this.getDecrypt() //解密秘钥
			// isLogin()

      // console.log(options, 'options----app----');
			const data = {
				// middlemanId: options.query.middlemanId || 0,
				inviteCode: options.query.inviteCode || 0 ,
				putInId: Number(options.query.putInId) || null,
				clueToken: options.query.clue_token || null,
				reqId: options.query.req_id || null, // 请求下发的id
				advertiserId: options.query.advertiser_id || null, // 账号id
				adId: options.query.adv_id || null,
				promotionId: options.query.promotion_id || null, // 广告id
				projectId: options.query.project_id || null, // 项目id
				clickId: options.query.clickid || null,
				agentId: Number(options.query.agentId) || null // 代理商ID
			}
			// 获取的信息存入缓存
			// this.setAppDataMethod(data)
			await refreshlogin(data)
		},
		onShow: async function() {
			// console.log(app, 'app');
			const res = await RequestApi.getAppConfig()
			// console.log(res, 'rse');
			if (res.data) {
				// this.setAppInfoMethod(app.getAppInfo(''))
				this.setAppInfoMethod(app.getAppInfo(res.data.appConfig.appName || ''))
				this.setAppConfigMethod(res.data.appConfig)
			}
			// app.updateApp()
		},
		methods: {
			...mapMutations('appInfo', ['setAppConfigMethod']),
			...mapMutations('appInfo', ['setAppInfoMethod', 'setAppDataMethod']),
			...mapMutations('userInfo', ['setInfoMethod']),
			async getDict() {
				let {data} = await RequestApi.getDict()
				data.forEach(item => {
					Dict.setDict(item.dictType, item.dictDataList)
				})
			},
			getDecrypt() {
				uni.setStorageSync('publicKey',
					'MIICWgIBAAKBgHJvnqebwwkTy/6Tq54C2c6zZUUusJTk6F4boPNKJYVV+UyVmX3IcUGVEwwS0mcMv+iFgrETlTG97n8HSS9Bs9iuoJhfmd3OD2vjpGENaBJ52rEVm9YF4iNufthswGG7Z9D20yVOBxi62soa5nIb5QCG5s0Qir5hYWwfuDpAN/trAgMBAAECgYBetGtrsKeHMqAHTnSf7yIMQ0ETMSGoB40anOjljz5gC5emvsPpaeH48YNy4XzJFa8Yoq1XGKrHILVo4UG63zgThW3KOzwlC7LVgzBlsb0cYBCSRJ9VJULjC4tAgZy3+O3DoriFdf6yJIF526rbV8GjUkWdeq4ojtNhjf02+PQwIQJBALuI2hDiwAfY2dFP1sztxbC21xCESpfW2KVSVEQ1ztMC3dzewM/3aY1BFzad/VCXZXuyaCpqMqOEwwf/TT8ME5ECQQCcNulMH0poVk/P0OnLQb+wbR54AfEzQsF1mrzvqff9IXIkrrqVT7X1uMh9aVORJwwhmzAh45rAW/BdAQUHWWk7AkBaX0Km7H6ZyXh+E7lxnAuucw4E2ZuQvGo+kQQmsr9ulG0SKQ5FqfblqT5khZIzKiIvj/P+rJqmji3mRrOU9F7hAkBgrneLfl493xV8aC8adjHeTlqqKYGPmUREtiUzK33pM3cCjwW5fWD/mIK1Y6et0X3nmrWac9SGMyC7XvMuzj6bAkBB4gbLDGJuhPxRr3rpkx4tBQT19L/vo/FeXARvCzVU4GlWoHgM5wL7DGeMa7PB3bCwsP4Bb1RceRDM2RcMsebl'
				)
			}
		},
		onHide: function() {},
		onError: (err) => {

		}
	}
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	 @import "uview-ui/index.scss";

  @font-face {
    font-family: 'pc'; /* 你可以给字体起一个别名 */
    src: url('static/font/PingFang SC coarse.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
  }
</style>
